#!/bin/sh
curl $answer_path -o answer.zip
unzip -o answer.zip -d __answerBranch
# bash替换成sh
if [ -f "./__answerBranch/script.sh" ];then
  sed '1c #!/bin/sh' ./__answerBranch/script.sh > ./__answerBranch/script.sh.tmp
fi
if [ -f "./__answerBranch/script" ];then
  sed '1c #!/bin/sh' ./__answerBranch/script > ./__answerBranch/script.sh.tmp
fi
  mv ./__answerBranch/script.sh.tmp ./__answerBranch/script.sh
  sudo chmod 777 ./__answerBranch/script.sh
# 不同技术栈执行不同方法
if [[ "$(echo $image | grep "node")" != "" ]]
then
  echo "In order to be compatible with the old version, please write 'rm -rf spec \n mv ./__answerBranch/spec ./spec' in your script file"
  cp -rf ./__answerBranch/script.sh ./script.sh
  cp -rf ./ ../answer_temp
  cp -rf ../answer_temp ./answer
  rm -rf ../answer_temp

else
  echo "not node"
fi
if [[ "$(echo $image | grep "java")" != "" ]]
then
  sudo cp -rf ./__answerBranch ./answer
  sudo cp -rf ./src/main/* ./answer/src/main
else
  echo "not java"
fi
